package com.d0316.Z16;


public class Exception {
    String a;
    int b;
    public Exception(){

    }
    /*public Exception(String a,int b){
        this.a=a;
        this.b=b;
    }*/
    public void div(String a,int b)throws NumberFormatException,ArithmeticException{
      if(a=="abc"){
          throw new NumberFormatException("字符串不能为abc");
      }
      if(b==0){
          throw new ArithmeticException("除数不能为0");
      }
      this.a=a;
      this.b=b;
      Integer il=Integer.parseInt(a);//把字符串类型转换为整型；
        System.out.println(il/b);
    }

    public static void main(String[] args) {
        Exception exception = new Exception();
        try {
            exception.div("145", 0);
        } catch (NumberFormatException n) {
            n.printStackTrace();
        } catch (ArithmeticException a) {
            a.printStackTrace();
        }
    }
}
